package kr.hkit.powerjava.chther26.common;


import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.PreparedStatement;



public class DbUtil {

	public static void close(Connection con){
		if (con != null){
			try {
				con.close();
			} catch (SQLException e) {
				System.err.print(e);
			} finally {
				con = null;
				System.out.println("MySQL Connection close");
			}
		}
	}
	
	public static void close(PreparedStatement pstmt){
		if (pstmt != null){
			try {
				pstmt.close();
			} catch (SQLException e) {
				System.err.print(e);
			} finally {
				pstmt = null;
			}
		}
	}
	
	public static void close(PreparedStatement pstmt, Connection con){
		close(pstmt);
		close(con);
	}
	public static void close(ResultSet rs,PreparedStatement pstmt, Connection con){
		close(pstmt);
		close(con);
		close(rs);
	}

	public static void close(ResultSet rs) {
		// TODO Auto-generated method stub
		if (rs != null){
			try {
				rs.close();
			} catch (SQLException e) {
				System.err.print(e);
			} finally {
				rs = null;
			}
		}
	}
	
}
